home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / File.Type.Notes / FTN.42.XXXX < prev    next >
Encoding:
Text File  |  1989-07-23  |  15.5 KB  |  297 lines  |  [04] ASCII Text (0x0000)

  1. Apple II
  2. File Type Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. File Type:         $42 (66)
  8. Auxiliary Type:    All
  9.  
  10. Full Name:     File Type Descriptors
  11. Short Name:    File Type Names
  12.  
  13. Written by:    Matt Deatherage                                      July 1989
  14.  
  15. Files of this type contain File Type Descriptor tables.
  16. _____________________________________________________________________________
  17.  
  18.  
  19. Introduction
  20.  
  21. As applications continue to be assigned file type and auxiliary type 
  22. combinations, the task of user file identification becomes more complex.  If 
  23. someone has the list in "About File Type Notes" memorized, simply displaying 
  24. the file type and auxiliary type in hexadecimal is a suitable way of 
  25. identification.  However, few people have memorized this list.  Programs such 
  26. as the Finder have a need for this information in machine-readable form--not 
  27. just a list of ASCII strings describing file types, but a way to take a given 
  28. file's file type and auxiliary type and turn it into a string which describes 
  29. the file.  The Finder is not alone in this need, as parts of command shells, 
  30. and sometimes entire programs, exist simply to identify files.
  31.  
  32. Developer Technical Support (DTS) has taken this opportunity to create a data 
  33. structure that may be used by the Finder and any other application wishing to 
  34. identify files.  By using a separate file, the file identifiers can be updated 
  35. between System Software releases, at the discretion of DTS, by releasing new 
  36. descriptor files.  Other applications may use the same file without having to 
  37. reinvent the wheel.  Furthermore, the multiple-file structure introduced and 
  38. suggested in this Note allows developers to ship File Type Descriptor files 
  39. with their software that allow the Finder and other applications to properly 
  40. identify these files without a new release of the Finder (much as developers 
  41. can supply their own Finder icons).
  42.  
  43. Note:  Updated files, if and when released, will not result in 
  44.        changes being made to the System Software.  The files as shipped 
  45.        with the System Software will remain unchanged until the next 
  46.        System Software release.  Developer Technical Support reserves the 
  47.        right to release updated files for the convenience of those who 
  48.        wish to use them.
  49.  
  50.  
  51. The File Format
  52.  
  53. The file's format is designed to give full and fast access to any file 
  54. descriptor string, while still remaining flexible enough to grow and be 
  55. indicative of new features.  Each file has three main parts:  a header, an 
  56. index, and the strings.
  57.  
  58. The Header
  59.  
  60. The file begins with a header which describes all the entries in the file:
  61.  
  62. +000    Version    Word     Version number.  This is toolbox style, so 
  63.                             revision x.y would be stored as $0xyy.  x 
  64.                             is the major revision number; when this 
  65.                             value changes, it means that previously-
  66.                             written code will not be able to read this 
  67.                             file.  yy is the minor version number; 
  68.                             when it changes, there are new fields but 
  69.                             the old ones are in the same order.  This 
  70.                             Note describes version 1.0 of the File 
  71.                             Type Descriptor format.
  72. +002    Flags      Word     This word is all the flags words from all 
  73.                             the records combined using a binary OR 
  74.                             instruction.  The flags word for each 
  75.                             entry indicates the type of entry it 
  76.                             contains (see the section "The Index 
  77.                             Entries").  A particular bit in this word 
  78.                             will be set if there exists a record in 
  79.                             the file where the corresponding bit in 
  80.                             the flags word is set.  For example, bit 
  81.                             14 will be clear in this word if no index 
  82.                             entry has bit 14 set.
  83. +004    NumEntries Word     The number of entries in this file.
  84. +006    SpareWord  Word     Reserved for the application's use.  
  85.                             The Finder calculates a value for each 
  86.                             file and stores it in this field when the 
  87.                             file is read into memory.  This should be 
  88.                             zero in the file on disk.
  89. +008    IndexRecordSize
  90.                    Word     The number of bytes in each index record.
  91. +010    OffsetToIdx Word    Offset, from the beginning of the 
  92.                             file, to the first index entry.  This 
  93.                             field is provided so that other fields may 
  94.                             be added to the header at a later date 
  95.                             without breaking existing programs.
  96.  
  97. The Index Entries
  98.  
  99. The descriptions for each file type and auxiliary type assignment are pointed 
  100. to by index entries for each string.  If there is a string in the file that 
  101. should be displayed for a particular assignment, there will be an index entry 
  102. for it.  If there is not an entry in any of the loaded files (see the section 
  103. "Having More Than One File Type Descriptor File"), the string for file type 
  104. $0000, auxiliary type $00000000 should be displayed.
  105.  
  106. The index contains one index entry for every file type and auxiliary type 
  107. assignment or range (see below) in the descriptor file.  All index entries in 
  108. a given file are the same length (given in the header) so fast binary-
  109. searching algorithms may be performed.  Their format is as follows for files 
  110. with major version 1:
  111.  
  112. +000    Filetype   Word     The file type that should match for the 
  113.                             string to which this index entry points.
  114. +002    Auxtype    Long     The auxiliary type that should match for 
  115.                             the string to which this index entry 
  116.                             points.
  117. +006    Flags      Flag Word  A word, defined bit-wise, indicating the 
  118.                             type of match this entry contains.  The 
  119.                             following definitions apply if the bit in 
  120.                             question is set:
  121.                             Bit 15:  This record matches this file 
  122.                             type and any auxiliary type.  This bit 
  123.                             would be set, for example, for a record 
  124.                             for file type $FF (ProDOS 8 application).
  125.                             Bit 14:  This record matches this 
  126.                             auxiliary type and any file type.
  127.                             Bit 13:  This record is the beginning of a 
  128.                             range of file types and auxiliary types to 
  129.                             match this string.  Any file type and 
  130.                             auxiliary type combination falling 
  131.                             linearly between this record and the 
  132.                             record with the same offset and bit 12 set 
  133.                             should be given this string by default if 
  134.                             no specific match is found.
  135.                             Bit 12:  This record is the end of a range 
  136.                             of file types and auxiliary types to match 
  137.                             this string.  Any file type and auxiliary 
  138.                             type combination falling linearly between 
  139.                             the record with the same offset and bit 13 
  140.                             set and this record should be given this 
  141.                             string by default if no specific match is 
  142.                             found.
  143.                             Bits 11-0:  Reserved, must be set to zero 
  144.                             when creating files.
  145.  
  146. Note:  A range uses the file type and auxiliary type combined as a 
  147.        six-byte value, with the file type bytes as most significant.  For 
  148.        example, file type $15, auxiliary type $4000 would fall in the 
  149.        range that starts with file type $13, auxiliary type $0800 and 
  150.        ends with file type $17, auxiliary type $2000
  151.  
  152. +008    Offset     Word     The offset, from the beginning of the 
  153.                             file, to the Pascal string matching the 
  154.                             description in this index entry.  Note 
  155.                             that more than one index entry can point 
  156.                             to the same string.
  157.  
  158. The Strings
  159.  
  160. Since each index entry contains an offset to a string, it seems only logical 
  161. that somewhere in the file is a string for each index entry.  Apple recommends 
  162. that the strings be placed in an array at the end of the index for most 
  163. efficient use of space and ease in creating the file.
  164.  
  165.  
  166. General Truths
  167.  
  168. So programs using File Type Descriptor files or resources don't have to 
  169. construct all information about them each time they are opened, certain 
  170. characteristics will be true of all files.  The following are characteristics 
  171. which will always be true for files or resources with major revision number 
  172. $01:
  173.  
  174.   o  The strings describing the files must each be no more than 30 
  175.      characters long.
  176.   o  The entries must always be sorted primarily by ascending file type 
  177.      and secondarily by ascending auxiliary type.
  178.   o  Records that match file types or auxiliary types generically (for 
  179.      example, file type $FF and any auxiliary type) must contain zeroes 
  180.      for the wildcard field.  A descriptor for ProDOS 8 application 
  181.      files should have file type $00FF, auxiliary type $00000000 and 
  182.      bit 15 set in the flags word.  This record should be before any 
  183.      specific match for a file that has file type $FF and auxiliary 
  184.      type $0000, if such a record were to exist.  Similarly, records 
  185.      which match a certain auxiliary type and any file type should 
  186.      appear before records which match file type $00 and that auxiliary 
  187.      type.
  188.   o  The index entry marking the beginning of a range and the index 
  189.      entry marking the end of a range must not have any other index 
  190.      entries between them.
  191.   o  Range index entries may not have bit 14 set.
  192.  
  193.  
  194.  
  195. Having More Than One File Type Descriptor File
  196.  
  197. More than one File Type Descriptor file may exist in a given directory.  
  198. However, only one file may exist in a given directory with any auxiliary type 
  199. from $00000000 to $000000FF.  These files are provided by Apple Computer, Inc. 
  200. and should not be altered by anything containing carbon atoms.  Future 
  201. implementations of System Software reserve the right to assume undocumented 
  202. properties about File Type Descriptor files with auxiliary types smaller than 
  203. $00000100.  Editing of the strings in these files is not necessary, since 
  204. other files may contain strings to override the ones in these files.
  205.  
  206. There is no such restriction on auxiliary types of $00000100 or greater.
  207.  
  208. To provide flexibility in changing file descriptions, applications should 
  209. build in the capability to use as many File Type Descriptor files as are 
  210. present.  Files created by third-parties must follow the following two rules:
  211.  
  212.   o  The auxiliary type must not be lower than $00000100.  Auxiliary 
  213.      types below $0100 are reserved for Apple.
  214.  
  215.   o  The File Type Descriptors must not contain a match for file type 
  216.      $00 and auxiliary type $0000.  Such a descriptor contains the 
  217.      string to display for a file that does not match any other index 
  218.      entry.  This entry must only be contained in the File Type 
  219.      Descriptor with auxiliary type zero.
  220.  
  221. A file with auxiliary type zero must exist.  Others should be searched in 
  222. order of descending auxiliary type, with $FFFFFFFF having highest priority.  
  223. (This is why no file must contain a match for file type $00 and auxiliary type 
  224. $0000 except the Apple-supplied one; otherwise, no searching would ever be 
  225. done beyond the offending file.)  In this way, strings in the Apple-supplied 
  226. files may be superseded by other strings, without replacing or altering the 
  227. Apple-supplied file (a feat that would be difficult anyway, due to the offset 
  228. nature of the file structure).
  229.  
  230. Program Use of More Than One File
  231.  
  232. Applications should search the directory for as many of the given files as can 
  233. be found.  If none is found with auxiliary type $0000, then the application 
  234. should behave as if no files were found.  When searching for a description, a 
  235. separate search can be done on each file, stopping when a match is found.  The 
  236. search algorithm should return the "unknown" string when no specific match is 
  237. found in the Apple-supplied file, so the search process will always return 
  238. some string.  An application should never run out of File Type Descriptors 
  239. before finding a match.
  240.  
  241. Adding a File
  242.  
  243. Developers who wish to ship their own File Type Descriptor file with their 
  244. product may contact Developer Technical Support for assistance in creating the 
  245. file.
  246.  
  247.  
  248. Memory Considerations
  249.  
  250. An application (especially a ProDOS 8 application) may not wish to spend 
  251. valuable memory on files for file identification purposes, especially if 
  252. directory listings are not an important part of the application.  Since all 
  253. offsets in the File Type Descriptor files are offsets from the beginning of 
  254. the file, they may also be used with the ProDOS 8 or GS/OS SetMark call.  
  255. Disk-based searches will obviously be much slower, but could be used for 
  256. special instances (such as printing complete directories of disks as opposed 
  257. to displaying them, or for specific functions that identify files).
  258.  
  259.  
  260. About the Finder's Implementation
  261.  
  262. In Apple IIGS System Software 5.0, the Finder uses File Type Descriptor files.  
  263. The Finder's implementation is somewhat limited, as this is a first pass at 
  264. this new standard.  The following implementation notes apply to Finder 1.3:
  265.  
  266.   o  The Finder looks for the File Type Descriptor files in the Icons 
  267.      directory of the boot disk (pathname *:Icons).  It does not look 
  268.      in other directories or on other disks.
  269.   o  Up to 30 File Type Descriptor files will be loaded.
  270.   o  Two File Type Descriptor files are shipped with System Software 
  271.      5.0.  The first, FType.Main, contains file type descriptions for a 
  272.      small subset of file types, and no specific auxiliary types.  This 
  273.      file will be loaded on machines with 512K or less of memory.  The 
  274.      second file, FType.Aux, contains the rest of the descriptions 
  275.      shipped with System Software 5.0, as listed in "About Apple II 
  276.      File Type Notes" for July, 1989, and this file will be loaded in 
  277.      addition to the first on machines with more than 512K of memory.  
  278.      FType.Main has auxiliary type $0000; FType.Aux has auxiliary type 
  279.      $0001.  The Finder does not depend on the names, but on the 
  280.      auxiliary types and file types.
  281.   o  If the Finder cannot find any File Type Descriptor files in the 
  282.      *:Icons directory, it will terminate with fatal system error 
  283.      $4242.  If it can not find a File Type Descriptor file with 
  284.      auxiliary type $0000, it will terminate with fatal system error 
  285.      $4243.
  286.   o  The Finder will only use File Type Descriptor files with major 
  287.      version number $01.  Also, the file will not be used if it any 
  288.      bits in the flags word of the header other than bit 15 are set, or 
  289.      if the spare word in the header is not zero, or if there are zero 
  290.      entries in the file.  The Finder's search algorithm is fast, but 
  291.      currently does not handle special index entries other than for a 
  292.      given file type and any auxiliary type.
  293.  
  294.  
  295. Further Reference
  296. _____________________________________________________________________________
  297.     o    About Apple II File Type Notes